package cn.lfy.studentmanager.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.lfy.studentmanager.domain.Clbum;
import cn.lfy.studentmanager.domain.Department;

public interface ClbumDao {
	//实现新增
	@Insert("INSERT INTO clbum(name,did) VALUES(#{name},#{did})")
	@Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
	boolean add(Clbum clbum);

	
	//实现查询
	@Select("SELECT c.id, c.name, c.did, d.name as dname FROM clbum c "
			+ "INNER JOIN department d ON c.did=d.id limit #{start},#{limit}")
	List<Map<String, Object>> select(int start, int limit);
	

	//进行删除操作
	@Delete("DELETE FROM clbum WHERE id =#{id}")
	boolean delete(int id);
	
	//完成修改数据
	@Update("UPDATE clbum SET name=#{name}, did=#{did} WHERE id=#{id}")
	boolean update(int id,String name,int did);
	
	//完成分页，本质还是查询
	@Select("SELECT COUNT(*) FROM clbum")
	int getCount();
	
	//查询院表中所有name
	@Select("SELECT * FROM department")
	List<Department> selectAll();
	



}
